/*
    Dao FLTK2
    Copyright (C) 2010 Belousov Oleg <belousov.oleg@gmail.com>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

#include <fltk/Group.h>
#include <dao.h>

#include "widget.h"

static void group_begin(DaoContext *ctx, DValue *p[], int N) {
    fltk::Group* ptr = (fltk::Group*) DaoCData_GetData(p[0]->v.cdata);

    ptr->begin();
}

static void group_end(DaoContext *ctx, DValue *p[], int N) {
    fltk::Group* ptr = (fltk::Group*) DaoCData_GetData(p[0]->v.cdata);

    ptr->end();
}

static void group_add(DaoContext *ctx, DValue *p[], int N) {
    fltk::Group* ptr = (fltk::Group*) DaoCData_GetData(p[0]->v.cdata);
    fltk::Widget* widget = (fltk::Widget*) DaoCData_GetData(p[1]->v.cdata);

    ptr->add(widget);
}

static void group_remove(DaoContext *ctx, DValue *p[], int N) {
    fltk::Group* ptr = (fltk::Group*) DaoCData_GetData(p[0]->v.cdata);
    fltk::Widget* widget = (fltk::Widget*) DaoCData_GetData(p[1]->v.cdata);

    ptr->remove(widget);
}

static void group_resizable(DaoContext *ctx, DValue *p[], int N) {
    fltk::Group* ptr = (fltk::Group*) DaoCData_GetData(p[0]->v.cdata);
    fltk::Widget* widget = (fltk::Widget*) DaoCData_GetData(p[1]->v.cdata);

    ptr->resizable(widget);
}

//

static DaoFuncItem groupMeth[] = {
    { group_begin,      "begin(self:fltk_group)" },
    { group_end,        "end(self:fltk_group)" },

    { group_add,        "add(self:fltk_group, widget:fltk_widget)" },
    { group_remove,     "remove(self:fltk_group, widget:fltk_widget)" },
    { group_resizable,  "resizable(self:fltk_group, widget:fltk_widget)" },
    { NULL, NULL }
};

DaoTypeBase groupTyper = {
    "fltk_group",
    NULL,
    NULL,                       /* no constant number */
    groupMeth,                  /* methods */
    { &widgetTyper, NULL },     /* parent type */
    { NULL },
    NULL,
    NULL                        /* free by free() */
};
